﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Text;

namespace JuCheap.Core.Services.AppServices
{
    public class AutoMapperModelEntityMapper : DefaultModelEntityMapper
    {
        private readonly IMapper _mapper;

        public AutoMapperModelEntityMapper(IMapperAccesstor mapper, IServiceProvider serviceProvider) : base(serviceProvider)
        {
            _mapper = mapper.Mapper;
        }

        protected override TDestination AutoMap<TSource, TDestination>(TSource source)
        {
            return _mapper.Map<TSource, TDestination>(source);
        }

        protected override TDestination AutoMap<TSource, TDestination>(TSource source, TDestination destination)
        {
            return _mapper.Map(source, destination);
        }
    }
}
